package com.nolydake.swingnote.util;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import com.alibaba.druid.pool.DruidDataSourceFactory;

public class SQLiteUtil {

    /**
     * 初始化连接池
     * 
     * @return 连接池对象
     * @throws Exception
     */
    public static DataSource initDataSource(File file) throws Exception {

        Map<String, String> properties = new HashMap<String, String>();

        properties.put("url", "jdbc:sqlite:" + file.getAbsolutePath());
        properties.put("maxActive", "1");
        properties.put("initialSize", "1");
        properties.put("minIdle", "1");
        properties.put("testWhileIdle", "false");

        return DruidDataSourceFactory.createDataSource(properties);
    }
}
